#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MEMPOOLSIZE 1024
#define streq(a,b) (strcmp(a,b) == 0)
#define argeq(b) (strcmp(argv[1],b) == 0)

typedef uint8_t byte;

typedef struct memorypool{
  char pool[MEMPOOLSIZE];
  int used;
}MemoryPool;

MemoryPool mainpool;

char * PoolMalloc(int size){
  char * PR = & (mainpool.pool[mainpool.used]);
  mainpool.used ++;
  return PR;
}

void PoolFree(){
  
}

byte page[256];

byte *doOperator(char  *op){
  if (op[0] == '$') return &(page[*(doOperator(op+1))]);
  else if (op[0] == '\'') return (byte *)(op + 1);
  
}

int main(int argc,char ** argv){
  if (argc > 1){
    if (argeq("help")){
      printf("%s\n","BC v1.0 help");
    }
    else{
      memset(page, 0, sizeof(page));
      memset(mainpool.pool,0,MEMPOOLSIZE);
      FILE *WorkingFile = fopen(argv[1],"r");
      char temp[1024];
      while (fgets(temp, sizeof(temp), WorkingFile) != NULL){
        if (temp[0] == '\'') {
          for (int i = 1;i < strlen(temp + 1); i++){
            if (temp[i] == '\\'){
              if (temp[i+1] == 'n') printf("%c",'\n');
              else if (temp[i+1] == '\'') printf("%c",'\'');
              else if (temp[i+1] == '\\') printf("%c",'\\');
              else if (temp[i+1] == 'b') printf("%c",'\b');
              i++;
              continue;
            }
            if (temp[i] == '\'') break;
            printf("%c",temp[i]);
          }
          continue;
        }
        char *cmd = strtok(temp, " ");
        if (streq(cmd, "0")){
          
        }
      }
    }
  }
  else{
    printf("%s\n","BC v1.0");
  }
}
